﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace BLL.SysManage
{
    public class T_PUB_USER
    {
        private readonly DALL.SysManage.T_PUB_USER dal = new DALL.SysManage.T_PUB_USER();
        public T_PUB_USER()
        { }



        /// <summary>
        /// 智能提示获取用户姓名
        /// </summary>
        /// <returns></returns>
        public DataSet GetUserName()
        {
            return dal.GetUserName();
        }


        /// <summary>
        /// 获得用户信息包含所属店所属部门用户角色
        /// </summary>
        /// <param name="strWhere"></param>
        /// <returns></returns>
        public DataSet GetUserInfoByRole(string strRole)
        {
            string strWhere = string.Format(" and r.ROLE_ID={0}", strRole);
            return dal.GetUserInfoByRole(strWhere);
        }
      

        /// <summary>
        /// 得到用户信息包含所属店所属部门
        /// </summary>
        /// <param name="strDepartID"></param>
        /// <param name="strDepart"></param>
        /// <param name="strUserName"></param>
        /// <returns></returns>
        public DataSet GetUserInfo(string strBarchID,string strDepart,string strUserName)
        {
            string strWhere = " ";
            if (!string.IsNullOrEmpty(strBarchID))
            {
                strWhere += string.Format(" and u.BRANCH_ID='{0}'", strBarchID);
            }
            if (!string.IsNullOrEmpty(strDepart))
            {
                strWhere += string.Format(" and u.DEPARTMENT_ID='{0}'", strDepart);
            }
            if (!string.IsNullOrEmpty(strUserName))
            {
                strWhere += string.Format(" and u.USER_NAME like '%{0}%'", strUserName);
            }
            return dal.GetUserInfo(strWhere);
        }
        /// <summary>
        /// 通过用户名获得用户实体
        /// </summary>
        /// <param name="UserSymbol"></param>
        /// <returns></returns>
        public Model.SysManage.T_PUB_USER GetModelByUserSymbol(string UserSymbol)
        {
            return dal.GetModelByUserSymbol(UserSymbol);
        }

        public List<Model.SysManage.T_PUB_USER> GetModelListByDepart(string strDepart)
        {
            return GetModelList(" DEPARTMENT_ID='" + strDepart + "' and ISUSED = 1 ");
        }
        #region  Method
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.SysManage.T_PUB_USER model)
        {
            return dal.Add(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.SysManage.T_PUB_USER model)
        {
            return dal.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(int USER_ID)
        {

            return dal.Delete(USER_ID);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.SysManage.T_PUB_USER GetModel(int USER_ID)
        {

            return dal.GetModel(USER_ID);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetList(string strWhere)
        {
            return dal.GetList(strWhere);
        }

        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List<Model.SysManage.T_PUB_USER> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            return dal.GetListArray(strWhere);
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public DataSet GetAllList()
        {
            return GetList("");
        }
        #endregion
    }
}
